1. /* howpow2.cpp by K.Tsuru */
  2. // function ID = 002
  3. /*****************************************
  4. SNumber sub-function
  5. Return a value n which satisfies a condition p<= 2^n.
  6. e.g. p = 5 --> n = 3
  7. *****************************************/
  8. #ifndef TYPEDEF_H
  9. #include "typedef.h"
  10. #endif
  11. uint howpow2(uint p){
  12. if(p < 2) return 0;
  13. uint j = 0, k = 1;
  14. while(k < p){ k *= 2; j++; }
  15. return j;
  16. }

howpow2.cpp : last modifiled at 2015/09/06 16:07:02(410 bytes)
created at 2016/04/11 11:17:20
The creation time of this html file is 2017/10/07 10:54:15 (Sat Oct 07 10:54:15 2017).